const cloud = require('wx-server-sdk')
cloud.init()
const db = cloud.database()
exports.main = async (event, context) => {
  if(event.id == "" || event.id == undefined)
  {
    return { "error": 1, "code": 1001,"msg":"not found id"}
  }
  else
  {
    var id = event.id;
    try {
      if (event.type == "all")
      {
        await db.collection('wenjuan').where({
          _id: id
        }).remove();
        return await db.collection('user_dt').where({
          wjbh: id
        }).remove();
      }
      else
      {
        return await db.collection('user_dt').where({
          _id: id
        }).remove();
      }
      return { "error": 0, "code": 1000, "msg": "success" }
    } catch (e) {
      return { "error": 1, "code":1002,"msg": "search error" }
    }
  }
}